<?php
/* ******************************
 *	Overhead In aJax actions
 * ******************************
 */

include('../../../includes/classes/core.php');
 
$action 	= $_REQUEST['act'];
$error 		= '';
$data 		= '';
$user_id	= $_SESSION['USERID'];

switch ($action) {
    case 'get_list':
	    $count = $_REQUEST['count'];
	    $hidden = $_REQUEST['hidden'];
	    $id = $_REQUEST['id'];

	    $rResult = mysql_query("SELECT	`invoice_detail`.`id`,
										`invoice_detail`.`service`,
										`invoice_detail`.`unit`,
										`invoice_detail`.`amount`,
										`invoice_detail`.`tax`,
										'ჩვეულებრივი' as `vat_type`,
										`invoice_detail`.`vat`
								FROM	`invoice_detail`
								WHERE	`invoice_detail`.`invoice_id` = '$id'");

		$data = array(
			"aaData"	=> array()
		);

		if(!$rResult){
		    $error = 'Invalid query: ' . mysql_error();
		}else{
			while ( $aRow = mysql_fetch_array( $rResult ) )
			{
				$row = array();
				for ( $i = 0 ; $i < $count ; $i++ )
				{
					/* General output */
					$row[] = $aRow[$i];
				}
				$data['aaData'][] = $row;
			}
		}

        break;
    default:
       $error = 'Action is Null';
}

$data['error'] = $error;

echo json_encode($data);
?>